package com.loser.user.controller;

import com.loser.module.base.common.APiResponsePage;
import com.loser.module.base.common.ApiResponse;
import com.loser.rpc.user.dto.req.UserPageReq;
import com.loser.rpc.user.dto.req.UserSaveReq;
import com.loser.rpc.user.dto.req.UserUpdateReq;
import com.loser.rpc.user.dto.resp.UserInfoResp;
import com.loser.rpc.user.fallback.UserFeignFallBack;
import com.loser.user.mongo.handler.UserHandler;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试数据 接口
 *
 * @author loser
 * @date 2023-02-05  14:01
 */
@RestController
public class UserController extends UserFeignFallBack {

    @Autowired
    private UserHandler userHandler;

    @Override
    public ApiResponse<Boolean> save(@RequestBody UserSaveReq req) {
        return userHandler.save(req);
    }

    @Override
    public ApiResponse<Boolean> update(@RequestBody UserUpdateReq req) {
        return userHandler.update(req);
    }

    @Override

    public ApiResponse<Boolean> deleteById(@ApiParam(value = "id") @PathVariable Long id) {
        return userHandler.deleteById(id);
    }

    @Override
    public ApiResponse<UserInfoResp> getById(@ApiParam(value = "id") @PathVariable Long id) {
        return userHandler.getById(id);
    }

    @Override
    public APiResponsePage<UserInfoResp, Object> queryList(@RequestBody UserPageReq req) {
        return userHandler.queryList(req);
    }

}
